<template>
  <div class="move Allpadding Toppadding" v-if="hope">
      <my-head title="猫吃鱼会员购" :back="false"></my-head>
      <div class="move_city">
          <div class="move_dis" @click="changeCity">
            {{mustCity}}<van-icon name="arrow-down" />
          </div>
          <div class="move_type">
            <span v-for="(item,index) in hotSearch" :key="index">{{item.name}}</span>
          </div>
      </div>
      <div class="swiper1">
          <van-swipe :autoplay="2000" >
            <van-swipe-item v-for="(item, index) in images" :key="index">
                <img :src="item.image" />
            </van-swipe-item>
          </van-swipe>
      </div>

      <my-move :record='zhanlan'>
        <div class="tit">
             <span class="istit">{{zhanlanTit}}</span>
             <span>更多</span>
         </div>
      </my-move>

      <my-move :record='yanchu'>
        <div class="tit">
             <span class="istit">{{yanchuTit}}</span>
             <span>更多</span>
         </div>
      </my-move>

      <my-move :record='live'>
        <div class="tit">
             <span class="istit">{{liveTit}}</span>
             <span>更多</span>
         </div>
      </my-move>
      
      <my-hope :hope='hope'></my-hope>

  </div>
</template>
<script>
export default {
data() {
  return {
    mustCity:null,
    hotSearch:null,
    images:null,
    zhanlan:null,
    zhanlanTit:"精选展览",
    yanchu:null,
    yanchuTit:"热门演出",
    live:null,
    liveTit:"周末去哪儿",
    hope:null
  }
},
methods: {
   //点击城市跳转到城市列表
    changeCity(){
      this.$router.push({
            name:'city'
        })
    },
    //拿到当前城市的主体
    async getMoveType(){
      let res=await this.$ajax.getType({
        districtId: this.city.cityId,
        fromType: 102
      })
      console.log(res.data.hotSearch);
      this.hotSearch=res.data.hotSearch
    },
    
    //拿到当前城市的轮播图
    async getSwiper(){
      let res=await this.$ajax.postswiper({
        district: this.city.cityId,
        position: {
          postcore: 22,
           postsub: 0
           }
      })
      console.log(res.data.resource);
      this.images=res.data.resource
    },

    //n拿到当前城市的zhanlan
    async getZhanlan(){
      let res =await this.$ajax.getZhanlan({
          version: 133,
          page: 1,
          pagesize: 20,
          platform: 'web',
          area: this.city.cityId,
          p_type: '展览',
          style: 2,
          location: '114.2791,30.5724',
      })
      console.log(res);
      this.zhanlan=res.data.result.slice(0,8)
    },
     //n拿到当前城市的yanchu
    async getYanchu(){
      let res =await this.$ajax.getZhanlan({
            version: 133,
            page: 1,
            pagesize: 20,
            platform: 'web',
            area: this.city.cityId,
            p_type: '演出',
            style: 2,
            location: '114.2791,30.5724',
      })
      console.log(res);
      this.yanchu=res.data.result.slice(0,8)
    },

     //n拿到当前城市的Live
    async getLive(){
      let res =await this.$ajax.getZhanlan({
            version: 133,
            page: 1,
            pagesize: 20,
            platform: 'web',
            area: this.city.cityId,
            p_type: '本地生活',
            style: 2,
            location: '114.2791,30.5724',
      })
      console.log(res);
      this.live=res.data.result.slice(0,8)
    },
    
     //n拿到当前城市的tuijain
    async getHope(){
      let res =await this.$ajax.getZhanlan({
            version: 133,
            page: 1,
            pagesize: 20,
            platform: 'web',
            area: this.city.cityId,
            p_type: '全部类型',
            style: 2,
            location: '114.2791,30.5724',
      })
      console.log(res);
      this.hope=res.data.result
    },

},
mounted() {
  
      //vuex当前城市为空的话就去选择城市
      if(!this.city){
          this.$dialog.alert({
                title: '选择城市',
                message: '请选去选择你当前所在的城市',
            }).then(() => {
                this.$router.push({
                    name:'city'

                })
            });
      }else{
        this.mustCity=this.city.name
        this.getMoveType()
        this.getSwiper()
        this.getZhanlan()
        this.getYanchu()
        this.getLive()
        this.getHope()
      }
},
}
</script>

<style>

.move .myhead{
    background-image: linear-gradient(90deg,#442857,#5b2b50);
    background-size: 100% auto;
    background-position: 0 100%;
    
}
.move .van-nav-bar__title{
 color: #fff;
}
.move_city{
  display: flex;
  width: 100%;
  height: 40px;
  background-image: linear-gradient(90deg,#442857,#5b2b50);
    background-size: 100% auto;
    background-position: 0 100%;
    color: #fff;
    line-height: 40px;
    text-align: center;
    margin-top: 10px;
    border-radius: 10px;
    overflow: hidden;

}
.move_dis{
  font-weight: 700;
  font-size: 15px;
  width: 100px;
  height: 100%;
  
}
.move_type{
  width: 230px;
  display: flex;
  justify-content: start;
}
.move_type span{
  display: inline-block;
  margin-right: 10px;
  
}
.swiper1{
  width: 100%;
  height: 146px;
  border-radius: 10px;
  /* border: 1px solid black; */
   background-image: linear-gradient(90deg,#442857,#5b2b50);
    background-size: 100% auto;
    background-position: 0 100%;

}
.van-swipe img{
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.istit{
  font-weight: 700;
  font-size: 18px;
  color: #333;
}
</style>